package bookstore_mall.resp;

/**
 * 结果代码枚举

 * @date 2023/12/02
 */
public enum ResultCodeEnum {
    SUCCESS(0,"成功"),
    FAIL(4001,"失败"),
    NOT_FOUND(4004,"接口不存在"),
    FORBIDDEN(4003,"拒绝访问"),
    UNAUTHORIZED(4004,"未认证（签名错误）"),
    NOT_AUTH(4010,"无权限访问"),
    OPERATION_FAIL(4011,"操作失败"),
    NOT_LOGIN(4012,"未登录"),
    PARAM_ERROR( 4013, "参数错误"),
    PARSE_ERROR( 4014, "数据解析异常"),

    CATEGORY_NOT_FOUND( 4015, "分类不存在"),
    DATA_DUPLICATION( 4016, "数据重复"),
    EXPIRE( 4017, "已过期"),
    ILLEGAL( 4018, "非法参数"),
    CALL_FAILED( 4019, "调用失败"),

    RECHARGE_FAILED(5020, "充值失败"),
    QUERY_BALANCE_FAIL(5021, "余额查询失败"),
    QUERY_BALANCE_STATUS_FAIL(5022, "查询订单失败"),

    INTERNAL_SERVER_ERROR(5000,"服务器内部错误"),

    USER_NOT_FOUND(1001, "用户不存在"),
    PASSWORD_ERROR(1002, "密码错误");
//    NULL_POINT( 2002, "空指针异常"),
//    PARAM_ERROR( 2001, "参数错误"),
//    PARAMS_ERROR(4000,"请求参数错误"),
//    PARAMS_NULL(4000,"请求参数为空"),
//    NULL_ERROR(4001,"请求数据为空"),



    /**
     *响应状态码
     */
    private Integer code;
    /**
     * 响应信息
     */
    private String message;
    ResultCodeEnum(Integer code, String message){
        this.code=code;
        this.message=message;
    }
    public static String getMessageByCode(Integer code) {
        for (ResultCodeEnum resultCode : ResultCodeEnum.values()) {
            if (resultCode.getCode().equals(code)) {
                return resultCode.getMessage();
            }
        }
        return "未知状态码";
    }


    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
